﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master"
    Inherits="User_Route_List" CodeFile="User_Route_List.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>巡店督导线路维护</title>
    <script language="javascript" type="text/javascript">
        function expandcollapse(obj, row) {
            var div = document.getElementById(obj);
            var img = document.getElementById('img' + obj);

            if (div.style.display == "none") {
                div.style.display = "block";
                if (row == 'alt') {
                    img.src = "../images/collapse.gif";
                }
                else {
                    img.src = "../images/collapse.gif";
                }
                //img.alt = "Close to view other Customers";
                img.alt = "关闭查看客户信息";
            }
            else {
                div.style.display = "none";
                if (row == 'alt') {
                    img.src = "../images/expand.gif";
                }
                else {
                    img.src = "../images/expand.gif";
                }
                img.alt = "展开查看客户信息";
            }
        }
        function setRadio(nowRadio) {
            var myForm, objRadio;
            myForm = document.forms[0];
            //alert(myForm);
            for (var i = 0; i < myForm.length; i++) {
                if (myForm.elements[i].type == "radio") {
                    objRadio = myForm.elements[i];
                    ///alert(objRadio.name);
                    if (objRadio != nowRadio && objRadio.name.indexOf("gvChannelType") > -1 && objRadio.name.indexOf("RadioButton1") > -1) {
                        //alert(objRadio.name);
                        if (objRadio.checked) {
                            objRadio.checked = false;
                        }
                    }
                }
            }
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script>


        /*  
        将Date/String类型,解析为String类型.  
        传入String类型,则先解析为Date类型  
        不正确的Date,返回 ''  
        如果时间部分为0,则忽略,只返回日期部分.  
        */
        function formatDate(v) {
            if (v instanceof Date) {
                var y = v.getFullYear();
                var m = v.getMonth() + 1;
                var d = v.getDate();
                var h = v.getHours();
                var i = v.getMinutes();
                var s = v.getSeconds();
                var ms = v.getMilliseconds();
                if (ms > 0)
                    return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s
						+ '.' + ms;
                if (h > 0 || i > 0 || s > 0)
                    return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
                return y + '-' + m + '-' + d;
            }
            return '';
        }

       
    </script>
    <div>
        <table id="wsd_inputtable" style="width: 100%">
            <tr>
                <td class="tabletitle" colspan="8">
                    查询条件
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table width="100%">
                        <tr>
                            <td>
                                部门:
                            </td>
                            <td>
                                <asp:TextBox ID="txtOrg" runat="server" onkeydown="alert('请选择部门');return false;"
                                    OnTextChanged="txtOrg_TextChanged"></asp:TextBox>
                                <img src="../Resources/Images/search.png" alt="查找" style="cursor: pointer;" onclick="openPopup('../System/PopupOrganization.aspx?NameControlId=<%# txtOrg.UniqueID %>&ValueControlId=<%# txtHidOrg.UniqueID %>&UserListControlID=<%#txtHidUsers.UniqueID %>&SelectType=mulit','','300','500');" /><br />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="请选择部门!"
                        ControlToValidate="txtOrg" Display="Dynamic"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                <input id="txtHidOrg" type="hidden" runat="server" />
                                <input id="txtHidUsers" type="hidden" runat="server" />
                            </td>
                            <td>
                                巡店督导:
                            </td>
                            <td>
                                <asp:DropDownList runat="server" ID="ddlMobileUser" OnSelectedIndexChanged="ddlMobileUser_SelectedIndexChanged"
                                    AutoPostBack="true">
                                </asp:DropDownList>
                                <br />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="ddlMobileUser"
                                    runat="server" ErrorMessage="请选择人员" Display="Dynamic"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                <asp:Button ID="btnAdd" runat="server" class="wsd_button2" Text="编辑路线" OnClick="btnAdd_Click" />
                                <asp:Button ID="btnUpadteRoute" runat="server" class="wsd_button2" Text="修改覆盖" 
                                    OnClick="btnUpadteRoute_Click" />
                                <asp:Button ID="btnAdd0" runat="server" class="wsd_button2" Text="初始化路线" OnClick="btnAdd0_Click"
                                    OnClientClick="return confirm('确定将为用户初始化路线？');" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table><br />
        <table id="wsd_listtable" width="100%" >
            <tr>
                <td style="width: 100%">
                    <asp:GridView BorderWidth="0" Width="100%" ID="gvChannelType" runat="server" AutoGenerateColumns="False"
                        EmptyDataText="没有可显示的数据." EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"
                        EnableEmptyContentRender="true" OnRowDataBound="gvChannelType_RowDataBound" DataKeyNames="ROUTENUMBER" GridLines="None">
                        <HeaderStyle CssClass="titlist" />
                        <EmptyDataRowStyle HorizontalAlign="Center" Font-Bold="True"></EmptyDataRowStyle>
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <a href="javascript:expandcollapse('div<%# Eval("ROUTENUMBER") %>', 'one');">
                                        <img id="imgdiv<%# Eval("ROUTENUMBER") %>" alt="点击展开或隐藏客户 <%# Eval("ROUTENUMBER") %>"
                                            width="9px" border="0" src="../images/expand.gif" />
                                    </a>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="线路号码" DataField="ROUTENUMBER" />
                            <asp:BoundField HeaderText="线路描述" DataField="DESCRIPTION" />
                            <asp:TemplateField HeaderText="是否有序">
                                <ItemTemplate>
                                    <b>
                                        <%# Eval("ROUTEFORCE").ToString() == "1" ? "<font size='3' color='green'>√</font>" : "<font size='3' color='red'>×</font>"%></b>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="调整门店拜访顺序">
                                <ItemTemplate>
                                    <a id="aChangeRoute" runat="server">调整</a>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="操 作" Visible="false">
                                <ItemTemplate>
                                    <a id="aDel" onclick="return confirm('确定要删除吗?')" runat="server" style="text-decoration: none">
                                        删 除</a>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                
                                    <tr id="div<%# Eval("ROUTENUMBER") %>" style="display: none;">
                                        <td colspan="100%">
                                            <div  style=" position: relative;
                                                left: 15px; overflow: auto; width: 97%">
                                                <asp:GridView BorderWidth="1" Width="100%" ID="gvCustomerList" runat="server" AutoGenerateColumns="False"
                                                    EmptyDataText="没有可显示的数据." EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"
                                                    OnRowDataBound="Grid_RowDataBound" EnableEmptyContentRender="true"  GridLines="None">
                                                    <HeaderStyle CssClass="titlist" />
                                                    <Columns>
                                                        <asp:TemplateField HeaderText="ID" Visible="false">
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblID" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="RCID" Visible="false">
                                                            <ItemTemplate>
                                                                <asp:Label runat="server" ID="lblRCID" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:BoundField HeaderText="编号" DataField="ID" ReadOnly="true" />
                                                        <asp:BoundField HeaderText="门店名称" DataField="NAME" ReadOnly="true" />
                                                        <asp:BoundField HeaderText="销售渠道" DataField="Channel" ReadOnly="true" />
                                                        <asp:BoundField HeaderText="地址" DataField="ADDRESS_LINE" ReadOnly="true" />
                                                        <asp:BoundField HeaderText="序号" DataField="SEQUENCE" ControlStyle-Width="40" />
                                                    </Columns>
                                                    <RowStyle CssClass="evenline" />
                                                    <AlternatingRowStyle CssClass="oddline" />
                                                    <PagerSettings Visible="true" />
                                                </asp:GridView>
                                            </div>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <RowStyle CssClass="evenline" />
                        <AlternatingRowStyle CssClass="oddline" />
                        <PagerSettings Visible="False" Mode="NumericFirstLast" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
        <br />
        <table id="wsd_inputtable" style="width: 100%">
            <tr>
                <td width="100%" class="tabletitle">
                    操作选项
                </td>
            </tr>
            <tr>
                <td class="buttonarea" style="text-align: right;">
                    <asp:Button ID="btnExport" runat="server" class="wsd_button2" Text="导出Excel" OnClick="btnExport_Click" />
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
